package com.lakeworks.web.controller.core;

import com.lakeworks.common.core.controller.BaseController;
import com.lakeworks.common.core.domain.AjaxResult;
import com.lakeworks.common.core.page.TableDataInfo;
import com.lakeworks.domain.status.StaPickup;
import com.lakeworks.service.IStaPickupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 入厂单状态Controller
 *
 * @author lake
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/post/pickup")
public class StaPickupController extends BaseController {
    @Autowired
    private IStaPickupService staPickupService;

    /**
     * 查询入厂单状态列表
     */
    @GetMapping("/list")
    public TableDataInfo list(StaPickup staPickup) {
        startPage();
        List<StaPickup> list = staPickupService.selectStaPickupList(staPickup);
        return getDataTable(list);
    }

//    /**
//     * 导出入厂单状态列表
//     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, StaPickup staPickup)
//    {
//        List<StaPickup> list = staPickupService.selectStaPickupList(staPickup);
//        ExcelUtil<StaPickup> util = new ExcelUtil<StaPickup>(StaPickup.class);
//        util.exportExcel(response, list, "入厂单状态数据");
//    }

    /**
     * 获取入厂单状态详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(staPickupService.selectStaPickupById(id));
    }

    /**
     * 新增入厂单状态
     */
    @PostMapping
    public AjaxResult add(@RequestBody StaPickup staPickup) {
        return toAjax(staPickupService.insertStaPickup(staPickup));
    }

    /**
     * 修改入厂单状态
     */
    @PutMapping
    public AjaxResult edit(@RequestBody StaPickup staPickup) {
        return toAjax(staPickupService.updateStaPickup(staPickup));
    }

    /**
     * 删除入厂单状态
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(staPickupService.deleteStaPickupByIds(ids));
    }
}
